package reflect;

import java.lang.reflect.Constructor;

/**
 * 使用有参构造器进行实例化
 */
public class ReflectDemo3 {
    public static void main(String[] args) throws Exception {
        Person p = new Person("李四",22);
        System.out.println(p);

        Class cls = Class.forName("reflect.Person");
       Constructor c = cls.getConstructor(String.class,int.class);
       Object obj =  c.newInstance("王五",62);
        System.out.println(obj);

    }
}
